package com.um.springboot.starter.exception;

import com.um.springboot.starter.orm.entity.Response;
import org.springframework.core.annotation.Order;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 业务异常信息返回
 * @author renjunwei
 * @date 2020/9/19 09:37
 */
@Order(99)
@ControllerAdvice
public class ServiceExceptionHandler {

    @ExceptionHandler(ServiceException.class)
    @ResponseBody
    public Response serviceExceptionHandler(ServiceException e) {
        return Response.failed(e.getErrCode(), e.getMsg(), e.getData());
    }

}
